package org.trc.network.util;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.CoordinateFilter;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */

public class CoordinateTransform implements CoordinateFilter { // From geography coordiante to projected coordiante
    //地图参数
    int resolution;
    double minX;
    double maxY;
    double dX;
    double dY;

    public CoordinateTransform(double minX, double maxY, double dX, double dY, int resolution) {
        this.minX = minX;
        this.maxY = maxY;
        this.dX = dX;
        this.dY = dY;
        this.resolution = resolution;
    }

    //坐标转换
    public void filter(Coordinate coordinate) {
        coordinate.x = (int) ((coordinate.x - minX) * resolution / dX);
        coordinate.y = (int) ((maxY - coordinate.y) * resolution / dY);
    }
}
